﻿/*
 * 上传手工报告。 szj 2010-4-13
 * 
 * 
 * */
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using EQT.Bll;
using EQT.Model;
using EQT.Dal;
using System.Collections.Generic;

/// <summary>
/// UploadReport 的摘要说明
/// </summary>
public class UploadReport:IUploadFile
{
    private DaProductCheckContract dacontract = DevFuture.Common.WorkContext.AppCtx.GetObject("DaProductCheckContract") as DaProductCheckContract;
    private DaTfiles datf = DevFuture.Common.WorkContext.AppCtx.GetObject("DaTfiles") as DaTfiles;
    private DaDirFile dadf = DevFuture.Common.WorkContext.AppCtx.GetObject("DaDirFile") as DaDirFile;
    public UploadReport()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }

    #region IUploadFile 成员

    public void InitUpload(IUploadPage up, System.Collections.Specialized.NameValueCollection nvc)
    {
        #region 上传最终报告
        string report_id = nvc["id"];
        if (String.IsNullOrEmpty(report_id) || report_id.Trim().Length == 0)
        {
            Utility.SiteError("缺失所必需的参数【报告编号】", up.Response);
            return;
        }
        else
        {
            up.SetConfigValue("REPORT_ID",report_id);
            MoProductCheckContract mo = new MoProductCheckContract();
            mo.ReportId = report_id;
            dacontract.GetEntityEx(ref mo);
            up.SetPageTitle( String.Format("为报告【{0}】【{1}】上传检验报告：",
                mo.ReportId, mo.CorpName));
        }

        #endregion
    }

    public int Upload1(IUploadPage up, EQT.Model.MoTfiles file, string opter_id)
    {
        string report_id = up.GetConfigValue("REPORT_ID").ToString();
        
        try
        {
            return dacontract.UploadMannulReportFile(file, report_id, opter_id,datf,dadf);
        }
        catch (DalException de)
        {
            Utility.GlobalLog.Error("添加报告文件失败!", de);
            Utility.SiteError("添加报告文件失败!", up.Response);
            return -1;
        }
    }

    public int UploadedMuliti(IUploadPage up, System.Collections.Generic.List<EQT.Model.MoTfiles> files, string opter_id)
    {
        throw new Exception("The method or operation is not implemented.");
    }

    public string GetReturnUrl(IUploadPage up)
    {
        throw new Exception("The method or operation is not implemented.");
    }

    #endregion
}
